package com.vegetable.modules.entity.outbound.po;

import cn.hutool.core.date.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.Objects;

/**
 * <p>
 * 销售订货任务下达表
 * </p>
 *
 * @author wangruijie
 * @since 2024-03-27
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="SalesOrderTransmit对象", description="销售订货任务下达表")
public class SalesOrderTransmitPO {

    @ApiModelProperty(value = "商品分类")
    private String category;

    @ApiModelProperty(value = "商品分类")
    private Long categoryId;

    @ApiModelProperty(value = "查询开始时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private Date startTime;

    @ApiModelProperty(value = "查询结束时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private Date endTime;

    @ApiModelProperty(value = "走货时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private Date orderTime;

    @ApiModelProperty(value = "是否需要自己加工 0是 1否")
    private Integer selfProcessing;

    public Date getStartTime(){
        Date toDate = Objects.nonNull(startTime) ? startTime : new Date();
        return toDate;
    }

    public Date getEndTime(){
        Date toDate = Objects.nonNull(endTime) ? endTime : new Date();
        return DateUtil.endOfDay(toDate);
    }
}
